{
  config,
  pkgs,
  inputs,
  ...
}: {
  # Remove unecessary preinstalled packages
  environment.defaultPackages = [];
  services.xserver.desktopManager.xterm.enable = false;

  imports = [
    # ./acme.nix
    # ./nextcloud.nix
    ./scripts
  ];

  # boot.kernelPackages = pkgs.linuxPackages_latest;

  environment = {
    # Generic Packages (others are managed in `packages.nix`)
    systemPackages = with pkgs; [
      git
      curl
      wget
      acpi
      lm_sensors
      tlp
      dnsutils
      pciutils
      vulkan-headers
      vulkan-loader
      vulkan-tools
    ];
    # Set environment variables
    variables = {
      XDG_CONFIG_HOME = "$HOME/.config";
      XDG_CACHE_HOME = "$HOME/.cache";
      XDG_DATA_HOME = "$HOME/.local/share";
      XDG_STATE_HOME = "$HOME/.local/state";
      DISABLE_QT5_COMPAT = "0";
      NIXOS_OZONE_WL = "1";

      # Force AMDVLK - (opensource)
      AMD_VULKAN_ICD = "AMDVLK";
      VK_ICD_FILENAMES = "/run/opengl-driver/share/vulkan/icd.d/amd_icd64.json";

      # Force RADV - (proprietary)
      # AMD_VULKAN_ICD = "RADV";
      # VK_ICD_FILENAMES = "/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json";
      # FIX:
      __GL_SHADER_DISK_CACHE_PATH = "$XDG_CACHE_HOME/amd";
    };
  };

  # Install Fonts
  fonts = {
    fonts = with pkgs; [roboto openmoji-color terminus-nerdfont tamsyn];

    fontconfig = {
      hinting.autohint = true;
      defaultFonts = {emoji = ["OpenMoji Color"];};
    };
  };

  # Wayland stuff: XDG integration, allow sway to use brillo
  xdg = {
    portal = {
      enable = true;
      extraPortals = with pkgs; [
        xdg-desktop-portal-gtk
        xdg-desktop-portal-wlr
      ];
    };
  };

  # Nix settings, autocleanup and flakes
  nix = {
    settings = {
      auto-optimise-store = true;
      experimental-features = ["nix-command" "flakes"];
      builders-use-substitutes = true;
      substituters = ["https://hyprland.cachix.org" "https://nix-community.cachix.org"];
      trusted-public-keys = [
        "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
        "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
      ];
      allowed-users = ["rxf4e1"];
      keep-outputs = true;
      keep-derivations = true;
    };
    gc = {
      automatic = true;
      dates = "weekly";
      options = "--delete-older-than 3d";
    };
  };

  # Boot settings: clean /tmp/, latest kernel and bootloader
  boot = {
    supportedFilesystems = ["btrfs"];

    tmpOnTmpfs = true;
    cleanTmpDir = true;

    loader = {
      systemd-boot.enable = true;
      systemd-boot.editor = false;
      efi.canTouchEfiVariables = true;
      timeout = 2;
    };
  };

  # Set up locales (timezone and keyboard layout)
  time.timeZone = "America/Sao_Paulo";
  i18n.defaultLocale = "en_US.UTF-8";
  console = {
    font = "Lat2-Terminus16";
    keyMap = "br-abnt2";
  };

  # Set up users and enable sudo
  users = {
    enforceIdUniqueness = true;
    mutableUsers = true;
    users.rxf4e1 = {
      isNormalUser = true;
      # uid = 1001;
      group = "users";
      extraGroups = ["adbusers" "input" "wheel" "video" "audio"];
      shell = pkgs.bash;
    };
  };

  # systemd.coredump.enable = true;

  # Set up networking and secure it
  networking = {
    nameservers = ["9.9.9.9" "149.112.112.112"];
    wireless.iwd = {
      enable = true;
      settings = {
        General.AddressRandomization = "network";
        Settings = {
          AlwaysRandomizeAddress = true;
          EnableIPv6 = true;
        };
      };
    };
    firewall = {
      enable = false;
      #    allowedTCPPorts = [ 80 443 ];
      #    allowedUDPPorts = [ 80 443 ];
      #    allowPing = false;
    };
  };

  # Security
  security = {
    sudo.enable = false;
    doas = {
      enable = true;
      extraRules = [
        {
          users = ["rxf4e1"];
          keepEnv = true;
          persist = true;
        }
      ];
    };
    # Extra security
    protectKernelImage = true;
  };

  programs.adb.enable = true;
  programs.dconf.enable = true;

  # DBUS
  services = {
    dbus = {
      enable = true;
      packages = with pkgs; [dconf gcr];
    };
    udev = {
      enable = true;
      packages = with pkgs; [gnome.gnome-settings-daemon];
    };

    # Battery info & stuff
    upower.enable = true;
  };

  # Sound
  sound.enable = true;
  # hardware.pulseaudio.enable = true;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
  };

  # Set up hardware stuff: bluetooth opengl etc
  hardware = {
    bluetooth.enable = false; # disabled until need it
    openrazer.enable = true; # mice drivers
    opengl = {
      enable = true;
      driSupport = true;
      driSupport32Bit = false;
      extraPackages = with pkgs; [
        libdrm
        amdvlk
        # rocm-opencl-icd
        # rocm-opencl-runtime
      ];
    };
  };

  # Do not touch this
  system.stateVersion = "20.09";
}
